<?php

//echo "pase";
require_once 'jq-configfar.php';
//require_once ('/Applications/MAMP/htdocs/HS/jqSuitePHP_4_1_2_2/jq-config.php');
// include the jqGrid Class

require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");


// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query

// Write the SQL Query

$grid->SelectCommand = "SELECT descFarmacologia,Presentaciones,Dosis,Indicaciones,Composicion
FROM farmacologia";

$grid->table = 'farmacologia'; 
//echo $grid->SelectCommand ;
// Set the table to where you update the data
//$grid->table = 'paciente';
// Set output format to json
$grid->dataType = 'json';
// Let the grid create the model

$grid->setColModel();

$grid->setUrl("Farmacia/Grid/gridfarmacia.php");

// Set the url from where we obtain the data
// Set the url from where we obtain the data
// Set some grid options
$grid->setGridOptions(array(
        "caption"=>"Medicamentos", 
        "width"=>680,
        "height"=>120,  
    "rowNum"=>20,
    "rowList"=>array(20,40,60),
    "hiddengrid"=>false,    
        "hidegrid"=>true,
    "shrinkToFit"=>false,
    "sortname"=>"descFarmacologia"
));

// Set the table to where you add the data 

$grid->setColProperty('descFarmacologia', array("label"=>"Descripci&oacute;n", "width"=>150));
$grid->setColProperty('Presentaciones', array("label"=>"Presentaciones", "width"=>100));
$grid->setColProperty('Dosis', array("label"=>"Dosis", "width"=>80));
$grid->setColProperty('Indicaciones', array("label"=>"Indicaciones", "width"=>200));
$grid->setColProperty('Composicion', array("label"=>"Composici&oacute;n", "width"=>140));

$customfar = <<<HCfar
jQuery("#idSelRowFarma").click(function(){
    var selfarma = jQuery('#gridFarmacos').jqGrid('getGridParam','selrow');
   
    if(selfarma)     
    {  
       var selfarmarow = jQuery('#gridFarmacos').jqGrid('getRowData',selfarma);
        
         document.getElementById('idOrcenMedica').value += selfarmarow.descFarmacologia +"  (" + selfarmarow.Presentaciones + ")  " + selfarmarow.Dosis;
        
       // document.nameformOrdenMedica.nameOrdenMedica.value += ""+ selfarmarow.descFarmacologia +"  (" + selfarmarow.Presentaciones + ")  " + selfarmarow.Dosis+"";
     
   }
	if(!selfarma) alert("No selected row");
    return false;
});
HCfar;
$grid->setJSCode($customfar); 


$grid->toolbarfilter = true; 
// Enable navigator

$grid->navigator = true;
// Enable only editing
//$grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false));

$grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false, "search"=>true));

// Enjoy
$grid->renderGrid('#gridFarmacos','#pagerFarmacos',true, null, null, true,true);
// we set the select for ship city 

//$grid->setSelect("ShipCity", "SELECT DISTINCT ShipCity, ShipCity AS CityName FROM orders ORDER BY 2", false, false, true, array(""=>"All"))

$conn = null;

?> 
 


